<template>
  <Title title="基本信息" style="margin-top: 8px" />
  <div class="baseInfo-wrapper" v-if="statisticsData">
    <div class="item-wrapper left-wrapper">
      <div class="item">
        <div class="label">在制产品数量</div>
        <div class="value">{{ toLocaleString(statisticsData.prdprodquantity) || 0 }}</div>
      </div>
      <div class="item">
        <div class="label">在制专案数量</div>
        <div class="value">{{ toLocaleString(statisticsData.prdprjctquantity) || 0 }}</div>
      </div>
    </div>

    <div class="center-wrapper">
      <div class="value">{{ statisticsData.weekprodhours || 0 }}</div>
      <div class="label">OTD</div>
    </div>

    <div class="item-wrapper right-wrapper">
      <div class="item">
        <div class="label">周投产工时</div>
        <div class="value">{{ toLocaleString(statisticsData.weekprodhours) || 0 }}</div>
      </div>
      <div class="item">
        <div class="label">组装人力总数</div>
        <div class="value">{{ toLocaleString(statisticsData.totalManpower) || 0 }}</div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref } from 'vue';
import Api from '@/api/index';
import Title from './title.vue';
import { toLocaleString } from '@/utils/util.js';

const statisticsData = ref(null);
const getApi = async () => {
  const res = await Api.mps.commandRoom.basicInfo();
  const { code, data } = res.data;
  if (code == 200) {
    statisticsData.value = {
      prdprodquantity: 9790,
      prdprjctquantity: 9790,
      weekprodhours: 200,
      totalManpower: 400,
      otd: '39%',
    };
  }
};

defineExpose({
  getApi,
});
</script>

<style lang="scss" scoped>
.baseInfo-wrapper {
  color: #fff;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  z-index: 99;
  height: 179px;
  display: flex;
  flex-direction: row;
  align-items: center;
  background: rgba(59, 97, 157, 0.2);
  position: relative;
  .item-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    align-items: center;
    position: absolute;
    padding: 19px 0px 11px;
    box-sizing: border-box;
    .item {
      display: flex;
      justify-content: center;
      flex-direction: column;
      .label {
        font-size: 16px;
        line-height: 16px;
        color: #eaf0ff;
      }
      .value {
        font-weight: bold;
        font-size: 22px;
        color: #ffffff;
        font-family: DIN Alternate, DIN Alternate;
        margin-top: 11px;
      }
    }
  }
  .left-wrapper {
    left: 48px;
  }
  .right-wrapper {
    right: 45px !important;
    .item {
      align-items: flex-end !important;
    }
  }
  .center-wrapper {
    position: absolute;
    left: 0px;
    right: 0px;
    margin: auto;
    width: 380px;
    height: 100%;
    background-image: url('../img/group@2x.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    .value {
      font-weight: bold;
      font-size: 30px;
      color: #ffffff;
    }
    .label {
      font-size: 20px;
      color: #cfd5e5;
    }
  }
}
</style>
